package com.itqianfeng;

import com.itqianfeng.dao.CustomerDao;
import com.itqianfeng.dao.OrderDao;
import com.itqianfeng.mapper.impl.CustomerMappingImpl;
import com.itqianfeng.pojo.Customer;
import com.itqianfeng.pojo.Order;

import java.util.Date;
import java.util.List;

public class Test {
    public static void main(String[] args) throws Exception {
        CustomerDao dao = new CustomerDao();
        // dao.delete("delete from customers where customer_id = ?", 13);
        // Customers customers = dao.findById("select * from customers where customer_id = ?", 1, new CustomersMapper());
        // System.out.println(customers);
        List<Customer> list = dao.findAll("select * from customers", new CustomerMappingImpl());
        list.forEach(System.out::println);

        // 容易发生RuntimeException
        // dao.saveOrUpdate(
        //         "update customers set first_name = ?, birth_date = ?, points = ? where customer_id = ?",
        //         "Gavin", "1990-01-01", 3000, 1);

        // dao.updateOrSave(
                // "insert into customers values(null,?,?,?,?,?,?,?,?)",
                // "Gavin", "King", new Date(), "000-000", "HN", "CS", "YL", 3000);


        //
        OrderDao orderDao = new OrderDao();
        // Order orders = orderDao.findById("", 1);
        // Orders orders = ordersDao.findById("select * from orders where order_id = ?", 1, new OrdersMapper());
        // System.out.println(orders);
        // List<Orders> list = ordersDao.findAll("select * from orders", new OrdersMapper());
        // list.forEach(System.out::println);

        // orderDao.deleteData("delete from orders where order_id = ?", 0);

        // orderDao.updateOrSave(
        //         "insert into orders values(null,?,?,?,?,?,?)",
        //         12, new Date(), 3, "HN", new java.sql.Date(12), 3);


    }
}
